<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php
/**
 * Product list template
 *
 * @see Mage_Catalog_Block_Product_List
 */
?>
<?php
    $_productCollection=$this->getLoadedProductCollection();
    $_helper = $this->helper('catalog/output');
    $_collectionSize = $_productCollection->count();
    $parentTemp =  get_class($this->getParentBlock());
    $categoryName = "";
    if(strpos($parentTemp,"Search")){
        $typeStr = "Search List";
        $categoryName = "Search";
    }else{
        $typeStr = "Category List";
        $_category = Mage::registry('current_category');
        if(!empty($_category)){
            $categoryName = $_helper->categoryAttribute($_category, $_category->getName(), 'name');
        } 
    }
    
  
    
?>
<?php if(!$_collectionSize): ?>
    <div class="category-products"><p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p></div>
<?php else: ?>
    <div class="category-products">
        <div class="toolbar-top"><?php echo $this->getToolbarHtml() ?></div>
        <?php // List mode ?>
        <?php if($this->getMode()!='grid'): ?>
        <?php 
            $_iterator = 0;
            // List Mode            
            $_wImgList = 190;
            $_hImgList = 190;
            if(Mage::helper('themeframework/settings')->getProductsList_ImageRatio()!=0){
                $_ratioImgList = Mage::helper('themeframework/settings')->getProductsList_ImageRatio();
                if($_ratioImgList!='-1'){
                    $_hImgList = $_wImgList/$_ratioImgList;    
                }else{
                    $_hImgList = ($_wImgList * Mage::helper('themeframework/settings')->getProductsList_CustomHeight())/Mage::helper('themeframework/settings')->getProductsList_CustomWidth();
                }                        
            } 
              
            $altImgList = Mage::helper('themeframework/settings')->getProductsList_AltImg();
            $gutterList = Mage::helper('themeframework/settings')->getProductsList_Gutter(); 
        ?>
        <ol class="products-list" id="products-list">
        <?php foreach ($_productCollection as $i=>$_product): ?>
            <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>" <?php if($gutterList): ?>style="margin-bottom: <?php echo $gutterList; ?>px"<?php endif; ?>>
                <!-- Show Thumbnail -->
                <?php if (Mage::helper('themeframework/settings')->getProductsList_ShowThumbnail()): ?>
                <?php // Product Image ?>
                    <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
                        <?php if (Mage::helper('themeframework/settings')->getProductsList_ShowLabel()):?>
                            <!--show label product - label extension is required-->
                            <?php Mage::helper('productlabels')->display($_product);?>
                        <?php endif ?>
                        <?php if($altImgList):?>
                            <img class="em-img-lazy img-responsive em-alt-hover" src="<?php echo $this->getSkinUrl('images/loading.gif') ?>" data-original="<?php echo $this->helper('catalog/image')->init($_product, $altImgList)->resize($_wImgList, $_hImgList); ?>" width="<?php echo $_wImgList ?>" height="<?php echo $_hImgList ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, $altImgList), null, true) ?>" />
                        <?php endif;?>
                        <img id="product-collection-image-<?php echo $_product->getId(); ?>" class="em-img-lazy img-responsive <?php if ($altImgList): ?>em-alt-org<?php endif ?>" src="<?php echo $this->getSkinUrl('images/loading.gif') ?>" data-original="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_wImgList, $_hImgList); ?>" width="<?php echo $_wImgList ?>" height="<?php echo $_hImgList ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
                    </a>
                <?php else:?>
                    <?php if (Mage::helper('themeframework/settings')->getProductsList_ShowLabel()):?>
                        <!--show label product - label extension is required-->
                        <?php Mage::helper('productlabels')->display($_product);?></a>
                    <?php endif ?>            
                <?php endif ?>
                
                
                <?php // Product description ?>
                <div class="product-shop">
                    <div class="f-fix">
                        <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
                        <!--product name-->
                        <?php if (Mage::helper('themeframework/settings')->getProductsList_ShowProductName()):?>
                            <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>" onclick="google_onProductListClick('<?php echo $_product->getSku() ?>','<?php echo str_replace(array('"',"'"),array('\\"',"\\'"), $_product->getName());?>','<?php echo $categoryName;?>','<?php echo $i;?>','<?php echo $_product->getProductUrl()?>','<?php echo $typeStr;?>','<?php echo $_product->getId()?>'); return !ga.loaded;">
                                <?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?>
                            </a></h2>
                            <?php
			                        // Provides extra blocks on which to hang some features for products in the list
			                        // Features providing UI elements targeting this block will display directly below the product name
			                        if ($this->getChild('name.after')) {
			                            $_nameAfterChildren = $this->getChild('name.after')->getSortedChildren();
			                            foreach ($_nameAfterChildren as $_nameAfterChildName) {
			                                $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName);
			                                $_nameAfterChild->setProduct($_product);
			                                echo $_nameAfterChild->toHtml();
			                            }
			                        }
			                ?>
                        <?php endif ?>  
  
                        <!--product description-->
                        <?php if (Mage::helper('themeframework/settings')->getProductsList_ShowDesc()): ?>
                            <div class="desc std">
                                <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
                                <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
                            </div> 
                        <?php endif ?> 
    					<!--show reviews-->
    					<?php if (Mage::helper('themeframework/settings')->getProductsList_ShowReviews()):?>
    						<?php if($_product->getRatingSummary()): ?>
    							<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
    						<?php endif; ?>
    					<?php endif ?>
						
                        <!--product price-->
                        <?php if (Mage::helper('themeframework/settings')->getProductsList_ShowPrice()): ?>
                            <?php echo $this->getPriceHtml($_product, true) ?>
                        <?php endif ?>
    
    					<div class="actions">
                        <?php if($_product->isSaleable()): ?>
    						<!--show button add to cart-->
                            <?php if (Mage::helper('themeframework/settings')->getProductsList_ShowAddtocart()): ?>
                                <button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
                            <?php endif ?>
                        <?php else: ?>
                            <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                        <?php endif; ?>
    
                        <!--show button add to compare-wishlist-->
                        <?php if (Mage::helper('themeframework/settings')->getProductsList_ShowAddto()): ?> 
                            <ul class="add-to-links">
                                <?php if ($this->helper('wishlist')->isAllow()) : ?>
                                    <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist" title="<?php echo $this->__('Add to Wishlist') ?>"><?php echo $this->__('Add to Wishlist') ?></a></li>
                                <?php endif; ?>
                                <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
                                    <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare" title="<?php echo $this->__('Add to Compare') ?>"><?php echo $this->__('Add to Compare') ?></a></li>
                                <?php endif; ?>
                            </ul>
                        <?php endif ?>
    					</div>
                    </div>
                </div>
            </li>
        <?php endforeach; ?>
        </ol>
        <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
    
        <?php else: ?>
    
        <?php // Grid Mode ?>
        <?php
            // set column count    
        	$_pageLayout = substr((str_replace(array('page/','.phtml'),'',Mage::app()->getLayout()->getBlock('root')->getTemplate())),0,1);            
            
            // Grid Mode            
            $_wImgGrid = 280;
            $_hImgGrid = 280;       
            if(Mage::helper('themeframework/settings')->getProductsGrid_ImageRatio()!=0){
                $_ratioImgGrid = Mage::helper('themeframework/settings')->getProductsGrid_ImageRatio();
                if(Mage::helper('themeframework/settings')->getGeneral_DisableResponsive(1)!=0){
                    switch(Mage::helper('themeframework/settings')->checkDevice()){
                        case 'desktop':
                            switch($_pageLayout){
                                case 3:
                                    $_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_Threecolumns(3);                    
                                    break;
                                case 1:
                                    $_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_Onecolumn(5);
                                    break;
                                default:
                                    $_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_Twocolumns(4); 
                                    break;
                            }
                            $_winWidth = 1200;
                            break;
                        case 'tablet':
                            switch($_pageLayout){
                                case 3:
                                    $_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_TabletThreecolumns(3);                    
                                    break;
                                case 1:
                                    $_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_TabletOnecolumn(5);
                                    break;
                                default:
                                    $_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_TabletTwocolumns(4); 
                                    break;
                            }
                            $_winWidth = 1024;
                            break;
                        case 'mobile': 
                            $_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_ItemsMobile(3);
                            $_winWidth = 320;
                            break;
                    }
                }else{
                    switch($_pageLayout){
                        case 3:
                            $_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_Threecolumns(3);                    
                            break;
                        case 1:
                            $_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_Onecolumn(5);
                            break;
                        default:
                            $_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_Twocolumns(4); 
                            break;
                    }
                    $_winWidth = 1200;                
                } 
                switch($_pageLayout){
                    case 3:
                        $_columnsContent = 12;                    
                        break;
                    case 1:
                        $_columnsContent = 24;
                        break;
                    default:
                        $_columnsContent = 18; 
                        break;
                }
                $_wImgGrid = (($_columnsContent/24) * $_winWidth)/$_columnCount - 20;
                if($_ratioImgGrid==-1){
                    $_hImgGrid = ($_wImgGrid*Mage::helper('themeframework/settings')->getProductsGrid_CustomHeight())/Mage::helper('themeframework/settings')->getProductsGrid_CustomWidth();
                }else{
                    $_hImgGrid = ($_wImgGrid/$_ratioImgGrid);
                }
            }   
            
            $altImgGrid = Mage::helper('themeframework/settings')->getProductsGrid_AltImg();    
               
            // Hover Effect
            switch(Mage::helper('themeframework/settings')->getProductsGrid_ConfigHover()){
                case 'enable':
                    $_classHoverEffect = 'emcatalog-enable-hover';
                    break;
                case 'medium_desktop':
                    $_classHoverEffect = 'emcatalog-disable-hover-below-desktop';
                    break;
                case 'tablet':
                    $_classHoverEffect = 'emcatalog-disable-hover-below-tablet';
                    break;
                case 'mobile':
                    $_classHoverEffect = 'emcatalog-disable-hover-below-mobile';
                    break;
                default:
                    $_classHoverEffect= '';
                    break; 
            }
            
            // Element Align Center
            switch(Mage::helper('themeframework/settings')->getProductsGrid_AlignCenter()){
                case 0:
                    $_classAlignCenter = '';
                    break;
                default:
                    $_classAlignCenter= 'text-center';
                    break; 
            }
            
            // Product Name Single Line
            switch(Mage::helper('themeframework/settings')->getProductsGrid_AutoProductName()){
                case 0:
                    $_classNameSingleLine = '';
                    break;
                default:
                    $_classNameSingleLine= 'em-productname-single-line';
                    break; 
            }
        ?>
    	<?php if ($_collectionSize > 0): ?>
            <div id="em-grid-mode">       
            	<ul class="emcatalog-grid-mode products-grid <?php echo $_classHoverEffect ?>">
                    <?php $i=0; foreach ($_productCollection as $_product): ?>   
                    <li class="item<?php echo $i == 0 ?' first':''; ?><?php echo $i+1 == $_collectionSize ?' last':''; ?>">
                        <div class="product-item">                        
                            <div class="product-shop-top">
                                <!-- Show Thumbnail -->
                                <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowThumbnail()): ?>
                                
                                    <a href="<?php echo $_product->getProductUrl() ?>" onclick="google_onProductListClick('<?php echo $_product->getSku() ?>','<?php echo str_replace(array('"',"'"),array('\\"',"\\'"), $_product->getName());?>','<?php echo $categoryName;?>','<?php echo $i;?>','<?php echo $_product->getProductUrl()?>','<?php echo $typeStr;?>','<?php echo $_product->getId()?>'); return !ga.loaded;"title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
                                        <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowLabel()):?>
                                            <!--show label product - label extension is required-->
                                            <?php Mage::helper('productlabels')->display($_product);?>
                                        <?php endif;?>
                                        
  <!-- you 产品list页面图片模糊 2016-09-07 -->
                                        <?php if($altImgGrid):?>
                                            <img class="em-img-lazy img-responsive em-alt-hover" src="<?php echo $this->getSkinUrl('images/loading.gif') ?>" data-original="<?php echo $this->helper('catalog/image')->init($_product, $altImgGrid)->resize(300, 300); ?>" width="<?php echo $_wImgGrid ?>" height="<?php echo $_hImgGrid ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, $altImgGrid), null, true) ?>" />
                                        <?php endif;?>
                                        <img id="product-collection-image-<?php echo $_product->getId(); ?>" class="em-img-lazy img-responsive <?php if ($altImgGrid): ?>em-alt-org<?php endif ?>" src="<?php echo $this->getSkinUrl('images/loading.gif') ?>" data-original="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(300, 300); ?>" width="<?php echo $_wImgGrid ?>" height="<?php echo $_hImgGrid ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /><span class="bkg-hover"></span>
  <!-- you 产品list页面图片模糊 2016-09-07 -->
                                                      
                                  </a>
                                <?php else:?>
                                    <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowLabel()):?>
                                        <!--show label product - label extension is required-->
                                        <?php Mage::helper('productlabels')->display($_product);?>
                                    <?php endif;?>
                                <?php endif; ?>
                                
                                <div class="bottom">
                                    <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowAddtocart()): ?>
                                    <div class="em-btn-addto <?php echo $_classAlignCenter ?> <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowAddtocart()==2): ?>em-element-display-hover<?php endif;?>">
                    					<?php if($_product->isSaleable()): ?>
                                            <!--show button add to cart-->                                            
            								<button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>');google_addToCart('<?php echo  $_product->getSku();?>','<?php echo str_replace(array('"',"'"),array('\\"',"\\'"), $_product->getName());?>','<?php echo $categoryName;  ?>','unknow','<?php echo $_product->getPrice();?>','<?php echo $_product->getId()?>')"/><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>                                            
            							<?php else: ?>
            								<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
            							<?php endif; ?>
            
                                        <!--show button add to compare-wishlist-->                                         
                                        <ul class="add-to-links">
                                            <?php if ($this->helper('wishlist')->isAllow()) : ?>
                                                <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist" title="<?php echo $this->__('Add to Wishlist') ?>"><?php echo $this->__('Add to Wishlist') ?></a></li>
                                            <?php endif; ?>
                                            <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
                                                <li><a href="<?php echo $_compareUrl ?>" class="link-compare" title="<?php echo $this->__('Add to Compare') ?>"><?php echo $this->__('Add to Compare') ?></a></li>
                                            <?php endif; ?>
                                        </ul>
                                    </div>
                                    <?php endif;?>
                                    <?php if(Mage::helper('core')->isModuleEnabled('EM_Quickshop') && Mage::helper('quickshop')->getConfig('enable')): ?>
                                    <div class="quickshop-link-container hidden-xs">
                                        <a href="<?php echo Mage::helper('quickshop/links')->addQuickShopLink($_product->getProductUrl()); ?>" class="quickshop-link" title="<?php echo $this->__('Quickshop') ?>"><?php echo $this->__('Quickshop') ?></a>
                                    </div> 
                                    <?php endif;?>
                                </div> 
                            </div>
            
                            <div class="product-shop">
                                <div class="f-fix">
                                    <!--product name-->
                                    <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowProductName()):?>					
                                    <h2 class="product-name <?php echo $_classAlignCenter ?> <?php echo $_classNameSingleLine ?> <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowProductName() == 2):?>em-element-display-hover<?php endif;?>"><a href="<?php echo $_product->getProductUrl() ?>"  title="<?php echo $this->stripTags($_product->getName(), null, true); ?>" onclick="google_onProductListClick('<?php echo $_product->getSku() ?>','<?php echo str_replace(array('"',"'"),array('\\"',"\\'"), $_product->getName());?>','<?php echo $categoryName;?>','<?php echo $i;?>','<?php echo $_product->getProductUrl()?>','<?php echo $typeStr;?>','<?php echo $_product->getId()?>'); return !ga.loaded;">
                                        <?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?>
                                    
                                    
                                    </a></h2>
				                    <?php
					                        // Provides extra blocks on which to hang some features for products in the list
					                        // Features providing UI elements targeting this block will display directly below the product name
					                        if ($this->getChild('name.after')) {
					                            $_nameAfterChildren = $this->getChild('name.after')->getSortedChildren();
					                            foreach ($_nameAfterChildren as $_nameAfterChildName) {
					                                $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName);
					                                $_nameAfterChild->setProduct($_product);
					                                echo $_nameAfterChild->toHtml();
					                            }
					                        }
					                ?>
                                    <?php endif; ?>
                                    
                                    <!--show reviews-->
                                    <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowReviews()):?>
                                        <div class="<?php if(Mage::helper('themeframework/settings')->getProductsGrid_ShowReviews() == 2):?>em-element-display-hover<?php endif;?> <?php echo $_classAlignCenter ?>"><?php echo $this->getReviewsSummaryHtml($_product, 'short') ?></div>                                        
                                    <?php endif; ?>
                                    
                                    <!--product price-->
                                    <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowPrice()): ?>
                                        <div class="<?php echo $_classAlignCenter ?> <?php if(Mage::helper('themeframework/settings')->getProductsGrid_ShowPrice() == 2): ?>em-element-display-hover<?php endif;?>"><?php echo $this->getPriceHtml($_product, true) ?></div>
                                    <?php endif; ?>
                                    
                                    <!--product description-->
                                    <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowDesc()): ?>
                                    <div class="desc std <?php echo $_classAlignCenter ?> <?php if(Mage::helper('themeframework/settings')->getProductsGrid_ShowDesc() == 2):?>em-element-display-hover<?php endif;?>">
                                        <?php 
                                            $shortdes =  $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description');
                                            if(strlen($shortdes)>100) { //dem ki tu chuoi $str, 80 la chieu dai muon quy dinh
                                                $strCutTitle = substr($shortdes, 0, 57); //cat 80 ki tu dau
                                                $shortdes = substr($strCutTitle, 0, strrpos($strCutTitle, ' '));
                                                $shortdes = substr_replace($shortdes ,"...",-3);
                                            }
                                            echo $this->stripTags($shortdes,null,true);
                                        ?>
                                    </div>
                                    <?php endif; ?>                                       					
                                </div>
                            </div>
                        </div> 
                    </li>   
        			<?php $i++;?>
        			<?php if($i >= $_collectionSize) break;?>
        			<?php endforeach; ?>
                </ul>
            </div>
            <?php endif; ?>
            <?php 
                if(Mage::helper('themeframework/settings')->getGeneral_DisableResponsive(1)!=0){
                    switch($_pageLayout){
                        case 3:
                            $_columnCountDesktop = Mage::helper('themeframework/settings')->getProductsGrid_Threecolumns(3);
                            $_columnCountDesktopSmall = Mage::helper('themeframework/settings')->getProductsGrid_DesktopSmallThreecolumns(3);
                            $_columnCountTablet = Mage::helper('themeframework/settings')->getProductsGrid_TabletThreecolumns(3);                    
                            break;
                        case 1:
                            $_columnCountDesktop = Mage::helper('themeframework/settings')->getProductsGrid_Onecolumn(5);
                            $_columnCountDesktopSmall = Mage::helper('themeframework/settings')->getProductsGrid_DesktopSmallOnecolumn(5);
                            $_columnCountTablet = Mage::helper('themeframework/settings')->getProductsGrid_TabletOnecolumn(5);
                            break;
                        default:
                            $_columnCountDesktop = Mage::helper('themeframework/settings')->getProductsGrid_Twocolumns(4);
                            $_columnCountDesktopSmall = Mage::helper('themeframework/settings')->getProductsGrid_DesktopSmallTwocolumns(4);
                            $_columnCountTablet = Mage::helper('themeframework/settings')->getProductsGrid_TabletTwocolumns(4); 
                            break;
                    }
                    $_columnCountMobile = Mage::helper('themeframework/settings')->getProductsGrid_ItemsMobile(3);
                }else{
                    switch($_pageLayout){
                        case 3:
                            $_columnCountDesktop = Mage::helper('themeframework/settings')->getProductsGrid_Threecolumns(3);                    
                            break;
                        case 1:
                            $_columnCountDesktop = Mage::helper('themeframework/settings')->getProductsGrid_Onecolumn(5);
                            break;
                        default:
                            $_columnCountDesktop = Mage::helper('themeframework/settings')->getProductsGrid_Twocolumns(4); 
                            break;
                    }               
                }
            ?>
            <script type="text/javascript">
            
                (function($) {
                    if (typeof EM == 'undefined') EM = {};
                    if (typeof EM.SETTING == 'undefined') EM.SETTING = {};
                    function getWindowWidth() {
                        var w = window;
                        var d = document;
                        var e = d.documentElement;
                        var g = d.getElementsByTagName('body')[0];
                        var x = w.innerWidth||e.clientWidth||g.clientWidth;
                    	return x;
                    };
                    
                    function setColumnCountGridMode(){  
                        var wWin = getWindowWidth();
                        if(EM.SETTING.DISABLE_RESPONSIVE==1){
                            var sDesktop = 'emcatalog-desktop-';
                            var sDesktopSmall = 'emcatalog-desktop-small-';
                            var sTablet = 'emcatalog-tablet-';
                            var sMobile = 'emcatalog-mobile-';
                            var sGrid = $('#em-grid-mode'); 
                            if(wWin>1200){
                                sGrid.removeClass().addClass(sDesktop+'<?php echo $_columnCountDesktop ?>');
                            }else{
                                if(wWin<=1200 && wWin>768){                                
                                    sGrid.removeClass().addClass(sDesktopSmall+'<?php echo $_columnCountDesktopSmall ?>');
                                }else{
                                    if(wWin<=768 && wWin>480){
                                        sGrid.removeClass().addClass(sTablet+'<?php echo $_columnCountTablet ?>');
                                    }else{
                                        sGrid.removeClass().addClass(sMobile+'<?php echo $_columnCountMobile ?>');   
                                    }                                
                                }
                            }
                        }else{
                            var sDesktop = 'emcatalog-desktop-';
                            var sGrid = $('#em-grid-mode');
                            sGrid.removeClass().addClass(sDesktop+'<?php echo $_columnCountDesktop ?>');
                        }
                        
                    };
                    
                    //Ready Function
                    $(document).ready(function() {
                        setColumnCountGridMode();
                    });
                    $(window).resize($.throttle(300,function(){
                        setColumnCountGridMode();  	   
                    })); 
                })(jQuery);
            </script>
        <?php endif; ?>
    
        <div class="toolbar-bottom em-box-03">
            <?php echo $this->getToolbarHtml() ?>
        </div>
    </div>
<?php endif; ?>
<!-- cpa 联盟代码统计 -->
    <script type="text/javascript">
    window.ad_category = '<?php echo $categoryName?>';   // required

    window._retag = window._retag || [];
    window._retag.push({code: "9ce8887751", level: 1});
    (function () {
        var id = "admitad-retag";
        if (document.getElementById(id)) {return;}
        var s=document.createElement("script");
        s.async = true; s.id = id;
        var r = (new Date).getDate();
        s.src = (document.location.protocol == "https:" ? "https:" : "http:") + "//cdn.lenmit.com/static/js/retag.min.js?r="+r;
        var a = document.getElementsByTagName("script")[0]
        a.parentNode.insertBefore(s, a);
    })()
</script>
<!-- cpa 联盟代码统计 -->
<!--  colorswatch -->
<?php
// Provides a block where additional page components may be attached, primarily good for in-page JavaScript
if ($this->getChild('after')) {
    $_afterChildren = $this->getChild('after')->getSortedChildren();
    foreach ($_afterChildren as $_afterChildName) {
        $_afterChild = $this->getChild('after')->getChild($_afterChildName);
        //set product collection on after blocks
        $_afterChild->setProductCollection($_productCollection);
        echo $_afterChild->toHtml();
    }
}
?>
